package com.itheima.demo06.Predicate;

import java.util.ArrayList;
import java.util.function.Predicate;

public class Demo05Test {
    public static void main(String[] args) {
        String[] arr = {"古力娜扎,女", "马尔扎哈,男", "迪丽热巴,女", "赵丽颖,女"};
        ArrayList<String> list = filter(arr, s -> {
            return s.split(",")[1].equals("女");
        }, s -> {
            return s.split(",")[0].length() == 4;
        });

        System.out.println(list);
    }

    public static ArrayList<String> filter(String[] arr, Predicate<String> pre1, Predicate<String> pre2) {
        ArrayList<String> list = new ArrayList<>();
        for (String s : arr) {
            boolean b = pre1.and(pre2).test(s);
            if (b) {
                list.add(s);
            }
        }
        return list;
    }
}
